<template>
    <div class="List">
        <table>
            <thead>
                <td style="width:100px">操作</td>
                <td style="width:450px">标题</td>
                <td>歌手</td>
                <td style="width:300px">专辑</td>
                <td style="width:125px">时长</td>
            </thead>
            <tbody @dblclick="getUrl(id)" v-for="({id,dt,ar,al,tns,name,item},index) in datalist" :key="item">
                <td>
                    <i>{{getIndex(index)}}</i>
                    <i class="fa fa-heart-o cursor" id="heart"></i>
                    <i class="fa fa-download cursor" id="download"></i>
                </td>
                <td>{{name}}
                    <a v-for="trans in tns" :key="trans">
                        <i>( {{trans}} )</i>
                    </a>
                </td>
                <td>{{ar[0].name}}</td>
                <td>{{al.name}}</td>
                <td>{{formatTime(dt)}}</td>
            </tbody>
        </table>
    </div>
</template>

<script>
import {
    ListAll
} from '@/library/api/api'
export default {
    name:'List',
    data() {
        return {
            datalist:{},
            num:"",
            no:[]
        }
    },
    props:{
        Id:{
            type:Number
        }
    },
    methods: {
        getUrl(id) {
            localStorage.musicId = id
            this.$store.commit('increment', id)
        },
        list() {
            ListAll({
                data:{
                    id:this.Id,
                    limit:100,
                    offset:1
                }
            }).then(res=>{
                // console.log(res.songs[0].id);
                this.datalist = res.songs.map(item=>{
                    return item
                })
                this.num = res.songs.length
            })
        },
        getIndex(index) {
            return index+1<10?'0'+(index+1):index+1
        }
    },
    watch: {
        $route() {
            this.list()
        }
    },
    created() {
        this.list()
    }
}
</script>

<style lang="scss" scoped>
@import './List.scss'
</style>
